package com.lanyang.generic;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liaochengli
 * @date 2025/2/19
 * @des
 */
public class TestGeneric {

    public static void main(String[] args) {

        //创建具体对象时指定泛型的数据类型
        Generic<String> genericString = new Generic<>("test");
        String obj = genericString.getObj();
        System.out.println(obj);

        Generic<Integer> genericInteger = new Generic<>(1);
        Integer objInteger = genericInteger.getObj();
        System.out.println(objInteger);


        //不指定类型时按照Object类型处理
        Generic objectGeneric = new Generic<>("obj");
        Object obj1 = objectGeneric.getObj();
        System.out.println(obj1);

        System.out.println(genericString.getClass() == genericInteger.getClass());

        ChildNormal childNormal = new ChildNormal();
        String value = childNormal.getValue();

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < 10; i++) {
            list.add(i);
        }

        list.stream().filter(i -> i > 5).forEach(System.out::println);
    }
}
